package com.xt.tea.service.impl;

import com.xt.tea.entity.domain.Desk;
import com.xt.tea.entity.domain.Tea;
import com.xt.tea.entity.domain.User;
import com.xt.tea.mapper.DeskMapper;
import com.xt.tea.mapper.TeaMapper;
import com.xt.tea.mapper.UserMapper;
import lombok.AllArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class WorkService extends BaseService{

    private final UserMapper userMapper;

    private final DeskMapper deskMapper;

    private final TeaMapper teaMapper;

    @Cacheable(key = "'user:'+#userId",sync = true)
    public User getUserById(Integer userId){
        return selectById(userMapper, userId);
    }

    @Cacheable(key = "'desk:'+#deskId",sync = true)
    public Desk getDeskById(Integer deskId){
        return selectById(deskMapper, deskId);
    }

    @Cacheable(key = "'tea:'+#deskId",sync = true)
    public Tea getTeaById(Integer deskId){
        return selectById(teaMapper, deskId);
    }
}
